"""
用Python在mysql中创建一个数据库woniudb,并建一个student表（id,name,sex,age,score）,
然后插入任意两条数据？（需要写出注释）（25分）
"""

import pymysql


connection = pymysql.connect(host="localhost",user="root",password="123456",port=8888,autocommit=True)

cursor = connection.cursor()

cursor.execute("create database if not exists {} charset utf8;".format("woniudb"))
cursor.execute("use woniudb")
cursor.execute("create table student(id integer primary key auto_increment,name varchar(50),sex char(2),age tinyint,score decimal(5,2))")
cursor.execute("insert into student values({},'{}','{}',{},{})".format(0,'张三','男',19,100.0))
cursor.execute("insert into student values({},'{}','{}',{},{})".format(0,'李四','女',19,100.0))
# 利用非空为真的特性来验证连接获取成功
if connection:
    connection.close()
    print("连接已经关闭")
else:
    print("连接关闭失败!")